feat(llm-core): SSE streaming parser with UTF-8 tail handling#469
Open
quangdang46 wants to merge 3 commits into
Open
feat(llm-core): SSE streaming parser with UTF-8 tail handling#469quangdang46 wants to merge 3 commits into
quangdang46 wants to merge 3 commits into
Conversation
Add consolidated PR backlog from 13 reference repos (A-J, ~80 features) and supporting docs (MASTER_GOAL_PROMPT, GOAL_DRIVEN_PROMPT, CONSOLIDATED_FINDINGS).
Implements a reusable SSE parser module in jcode-llm-core: - SseEvent with event-type interning - SseParser state machine (BOM, CR/LF/CRLF, data cap, chunked parsing) - SseStream futures::Stream wrapper with UTF-8 tail accumulation - 15 unit tests covering all parsing paths Refs: docs/pr-plans/E2-sse-parser.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements E2 — a reusable SSE streaming parser in
jcode-llm-coreto replace per-provider ad-hoc SSE parsing.What's Included
crates/jcode-llm-core/src/sse.rs(680 lines)SseEvent— parsed event withevent,data,id,retryfields. Event-type interning (Cow::Borrowed) for common Anthropic/OpenAI events eliminates per-event String allocation.SseParser— streaming state machine. Supports:feed()returns complete events;flush()handles stream-endSseStream<S>—futures::Streamwrapper convertingResult<Vec<u8>, _>→Result<SseEvent, _>. Handles UTF-8 multi-byte characters split across chunk boundaries.docs/pr-plans/E2-sse-parser.md(46 lines)Plan file with research summary, gap analysis, and implementation decisions.
Why a Shared Module?
Previously, SSE parsing was embedded per-provider (Anthropic has inline parsing; OpenRouter too). This module:
EventSource-compatibleSseStreamfor ergonomic provider codeVerification
cargo check -p jcode-llm-core— clean (0 new errors)cargo check(stream boilerplate; parser tests cover all parsing paths)Refs: #E2, docs/pr-plans/E2-sse-parser.md